home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cato / Xm / XmResolvePartOffsets.z / XmResolvePartOffsets
Encoding:
Text File  |  2002-10-03  |  8.4 KB  |  199 lines

  1.  
  2.  
  3.  
  4.      XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))  UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV  XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss - A function that allows writing of
  10.           upward-compatible applications and widgets
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.           ####iiiinnnncccclllluuuuddddeeee <<<<XXXXmmmm////XXXXmmmmPPPP....hhhh>>>>
  14.  
  15.           vvvvooooiiiidddd XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss ((((_w_i_d_g_e_t__c_l_a_s_s, _o_f_f_s_e_t))))
  16.                WWWWiiiiddddggggeeeettttCCCCllllaaaassssssss_w_i_d_g_e_t__c_l_a_s_s;;;;
  17.                XXXXmmmmOOOOffffffffsssseeeettttPPPPttttrrrr* _o_f_f_s_e_t;;;;
  18.  
  19.  
  20.      VVVVEEEERRRRSSSSIIIIOOOONNNN
  21.           This page documents version 1.2 of the Motif library.
  22.  
  23.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  24.           The use of offset records requires one extra global variable
  25.           per widget class.  The variable consists of a pointer to an
  26.           array of offsets into the widget record for each part of the
  27.           widget structure.  The XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss function
  28.           allocates the offset records needed by an application to
  29.           guarantee upward-compatible access to widget instance
  30.           records by applications and widgets.  These offset records
  31.           are used by the widget to access all of the widget's
  32.           variables.  A widget needs to take the following steps:
  33.  
  34.  
  35.             +o  Instead of creating a resource list, the widget creates
  36.                an offset resource list.  To help you accomplish this,
  37.                use the XXXXmmmmPPPPaaaarrrrttttRRRReeeessssoooouuuurrrrcccceeee structure and the XXXXmmmmPPPPaaaarrrrttttOOOOffffffffsssseeeetttt
  38.                macro.  The XXXXmmmmPPPPaaaarrrrttttRRRReeeessssoooouuuurrrrcccceeee data structure looks just
  39.                like a resource list, but instead of having one integer
  40.                for its offset, it has two shorts.  This is put into
  41.                the class record as if it were a normal resource list.
  42.                Instead of using XXXXttttOOOOffffffffsssseeeetttt for the offset, the widget
  43.                uses XXXXmmmmPPPPaaaarrrrttttOOOOffffffffsssseeeetttt.
  44.  
  45.                XmPartResource resources[] = {
  46.                  { BarNxyz, BarCXyz, XmRBoolean,
  47.                    sizeof(Boolean), XmPartOffset(Bar,xyz),
  48.                    XmRImmediate, (XtPointer)False }
  49.                };
  50.  
  51.  
  52.             +o  Instead of putting the widget size in the class record,
  53.                the widget puts the widget part size in the same field.
  54.  
  55.             +o  Instead of putting XXXXttttVVVVeeeerrrrssssiiiioooonnnn in the class record, the
  56.                widget puts XXXXttttVVVVeeeerrrrssssiiiioooonnnnDDDDoooonnnnttttCCCChhhheeeecccckkkk in the class record.
  57.  
  58.             +o  The widget defines a variable, of type XXXXmmmmOOOOffffffffsssseeeettttPPPPttttrrrr, to
  59.                point to the offset record.  This can be part of the
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 4/30/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))  UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV  XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  71.  
  72.  
  73.  
  74.                widget's class record or a separate global variable.
  75.  
  76.             +o  In class initialization, the widget calls
  77.                XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss, passing it a pointer to contain
  78.                the address of the offset record and the class record.
  79.                This does several things:
  80.  
  81.                Adds the superclass (which, by definition, has already
  82.                been initialized) size field to the part size field
  83.  
  84.                Allocates an array based upon the number of
  85.                superclasses
  86.  
  87.                Fills in the offsets of all the widget parts with the
  88.                appropriate values, determined by examining the size
  89.                fields of all superclass records
  90.  
  91.                Uses the part offset array to modify the offset entries
  92.                in the resource list to be real offsets, in place
  93.  
  94.             +o  The widget defines a constant which will be the index
  95.                to its part structure in the offsets array.  The value
  96.                should be 1 greater than the index of the widget's
  97.                superclass.  Constants defined for all Xm widgets can
  98.                be found in XXXXmmmmPPPP....hhhh.
  99.  
  100.                #define BarIndex (XmBulletinBIndex + 1)
  101.  
  102.  
  103.             +o  Instead of accessing fields directly, the widget must
  104.                always go through the offset table.  The XXXXmmmmFFFFiiiieeeelllldddd macro
  105.                helps you access these fields.  Because the
  106.                XXXXmmmmPPPPaaaarrrrttttOOOOffffffffsssseeeetttt and XXXXmmmmFFFFiiiieeeelllldddd macros concatenate things
  107.                together, you must ensure that there is no space after
  108.                the part argument.  For example, the following macros
  109.                do not work because of the space after the part (Label)
  110.                argument:
  111.  
  112.                XmField(w, offset, Label , text, char *)
  113.                XmPartOffset(Label , text)
  114.  
  115.                Therefore, you must not have any spaces after the part
  116.                (Label) argument, as illustrated here:
  117.  
  118.                XmField(w, offset, Label, text, char *)
  119.  
  120.                You can define macros for each field to make this
  121.                easier.  Assume an integer field _x_y_z:
  122.  
  123.                #define BarXyz(w) (*(int *)(((char *) w) + \
  124.                  offset[BarIndex] + XtOffset(BarPart,xyz)))
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 4/30/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))  UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV  XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  137.  
  138.  
  139.  
  140.           The parameters for XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss are defined below:
  141.  
  142.  
  143.           _w_i_d_g_e_t__c_l_a_s_s
  144.                     Specifies the widget class pointer for the created
  145.                     widget.
  146.  
  147.           _o_f_f_s_e_t    Returns the offset record.
  148.  
  149.  
  150.      RRRREEEELLLLAAAATTTTEEEEDDDD IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  151.           XXXXmmmmRRRReeeessssoooollllvvvveeeeAAAAllllllllPPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX)))).
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 4/30/98)
  196.  
  197.  
  198.  
  199.